﻿@{
    ViewBag.Title = "ArticleList";
}
@model Pagination<CW_Article>

<h2 class="sub-header">文章列表</h2>
<div>
    @Html.ActionLink("新增文章", "ArticleCreate", null, new { Class = "btn btn-primary" })
</div>
<hr />
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <thead>
            <tr>
                <th>#</th>
                <th>标题</th>
                <th>logo</th>
                <th>作者</th>
                <th style="width:500px;">简介</th>
                <th>发布</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.CheckBox("articleId", false, new { value = @item.ArticleId })
                    </td>
                    <td>
                        @item.Title
                    </td>
                    <td>
                        @if (!string.IsNullOrEmpty(item.Thumb))
                        {
                            <img src="@Url.Content("~/images/logo/")@item.Thumb" height="35" />
                        }                 
                    </td>
                    <td>@item.Author</td>
                    <td>@item.Abstract</td>
                    <td>@(item.IsShow == true ? "发布" : "未发布")</td>
                    <td>
                        @Html.ActionLink("修改", "ArticleEdit", new { id = @item.ArticleId }, new { Class = "btn btn-default" })
                        @using (Html.BeginForm("ArticleDelete", "Admin", new { id = @item.ArticleId }, FormMethod.Post, new { onsubmit = "return marksure();", style = "display:inline-block" }))
                        {
                            <input type="submit" class="btn btn-default" value="Delete" />
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
<nav>
    <ul class="pagination">       
        <li>
            @Html.ActionLink("<<", "ArticleList", new { page = 0 })
        </li>
        @for (int i = 0; i < Model.TotalPages; i++)
        {
            if(i==Model.PageIndex)
            {
                <li class="active">
                    @Html.ActionLink((i+1).ToString(), "ArticleList", new { page = i})
                </li>
            }
            else
            {
                 <li>
                    @Html.ActionLink((i+1).ToString(), "ArticleList", new { page = i})
                </li>
            }       
        }
        <li>
            @Html.ActionLink(">>", "ArticleList", new { page = Model.TotalPages-1>0?Model.TotalPages-1:0 })
        </li>
    </ul>
</nav>

